package com.admission.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;
import org.springside.modules.orm.Page;
import org.springside.modules.orm.PropertyFilter;

import com.admission.dao.SpecialArticleDao;
import com.admission.model.SpecialArticle;

@Repository
@Transactional
public class SpecialArticleManager {
	private SpecialArticleDao specialArticleDao;
	private ArrayInfoManager arrayInfoManager;
	
	
	/**
	 * 通过id找唯一对象，无返回null
	 * 
	 * @param id
	 * @return
	 */
	public SpecialArticle getById(String id) {
		return specialArticleDao.findUniqueBy("id", id);
	}
	
	/**
	 * 保存
	 * 
	 * @param Entity
	 * @return
	 */
	public void save(SpecialArticle entity) throws Exception{
		specialArticleDao.save(entity);
	}
	
	/**
	 * 批量删除
	 */
	public void deleteByIds(String ids){
		for(String id : ids.split(",")){
			specialArticleDao.delete(id.trim());
		}
	}

	public Page<SpecialArticle> getPage(Page<SpecialArticle> page){
		return specialArticleDao.findPage(page);
	}
	
	
	/**
	 * 通过filter分页查询
	 * 
	 * @param filters
	 * @return
	 */
	public Page<SpecialArticle> getPageByFilter(Page<SpecialArticle> page,List<PropertyFilter> filters) {
		return specialArticleDao.findPage(page,filters);
	}
	
	public String specialName(String name){
		return arrayInfoManager.checkConsult(name);
	}
	
	
	public SpecialArticleDao getSpecialArticleDao() {
		return specialArticleDao;
	}
	@Autowired
	public void setSpecialArticleDao(SpecialArticleDao specialArticleDao) {
		this.specialArticleDao = specialArticleDao;
	}

	public ArrayInfoManager getArrayInfoManager() {
		return arrayInfoManager;
	}
	@Autowired
	public void setArrayInfoManager(ArrayInfoManager arrayInfoManager) {
		this.arrayInfoManager = arrayInfoManager;
	}
	
	
	
}
